package com.zhang.gmall.realtime.utils;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @title:
 * @author: zhang
 * @date: 2022/1/3 22:29
 */
public class ThreadPoolUtil {

    private static ThreadPoolExecutor threadPoolExecutor = null;

    private ThreadPoolUtil(){
    }

    public static ThreadPoolExecutor getThreadPoolExecutor(){
        if (threadPoolExecutor==null){
            synchronized (ThreadPoolUtil.class){
                if (threadPoolExecutor==null){
                    threadPoolExecutor=new ThreadPoolExecutor(6,
                            12,
                            1L,
                            TimeUnit.MINUTES,
                            new LinkedBlockingDeque<>());
                }
            }
        }
        return threadPoolExecutor;
    }
}
